﻿using UnityEngine;
using System.Collections.Generic;

class AssetManager
{
    private static AssetManager _instance = null;

    private Dictionary<string, Texture2D> _loadedTexture;

    public static AssetManager GetInstance()
    {
        if (_instance == null)
        {
            _instance = new AssetManager();
        }

        return _instance;
    }

    private AssetManager()
    {
        _loadedTexture = new Dictionary<string, Texture2D>();
    }

    private void LoadTexture(string TextureName)
    {
        _loadedTexture[TextureName] = (Texture2D) Resources.Load(TextureName, typeof(Texture2D));
    }

    public Texture2D GetTexture(string TextureName)
    {
        if( ! _loadedTexture.ContainsKey(TextureName) )
        {
            LoadTexture(TextureName);
        }
        
        return _loadedTexture[TextureName];
    }
}

